//package com.yiyong.myabtis_genetion;
//
//import org.mybatis.generator.config.Configuration;
//import org.mybatis.generator.config.xml.ConfigurationParser;
//import org.mybatis.generator.exception.XMLParserException;
//import org.mybatis.generator.internal.DefaultShellCallback;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.mybatis.generator.api.MyBatisGenerator;
//
//import java.io.File;
//import java.io.IOException;
//import java.io.InputStream;
//import java.util.ArrayList;
//import java.util.List;
//
//public class MybatisGenetaionApplication {
//    private static Logger logger = LoggerFactory.getLogger(MybatisGenetaionApplication.class);
//
//    private static InputStream getResource(String fileName) {
//        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
//        InputStream inputStream = classLoader.getResourceAsStream(fileName);
//        return inputStream;
//    }
//
//    public static void main(String[] args) {
//        try {
//            boolean overwrite = true;
//            List<String> warnings = new ArrayList<>();
//            ConfigurationParser parser = new ConfigurationParser(warnings);
//            Configuration configuration = parser.parseConfiguration(getResource("generatorConfig.xml"));
//            // 创建一个ShellCallback对象，shellCallback接口是处理文件的创建和合并，默认是不支持文件合并的。
//            DefaultShellCallback defaultShellCallback = new DefaultShellCallback(overwrite);
//            MyBatisGenerator myBatisGenerator = new MyBatisGenerator(configuration, defaultShellCallback, warnings);
//            myBatisGenerator.generate(null);
//        } catch (Exception e) {
//            logger.error(e.getMessage(), e);
//        }
//    }
//
//    /**
//     * 是否是windows系统
//     *
//     * @return
//     */
//    private static boolean isNotWindows() {
//        return System.getProperty("os.name").toLowerCase().startsWith("windows");
//    }
//}
